package com.huans.action;

import com.huans.model.User;
import com.huans.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

/**
 * User Action
 * 
 * @author lich
 * 
 */
public class UserAction extends ActionSupport {
	/**
	 * 
	 */
	private static final long serialVersionUID = -7153051118746998395L;

	private String message;

	private String userId;

	private UserService userService;

	public String execute() {
		String userId = this.getUserId();
		User user = userService.find(userId);
		if (user != null) {
			this.setMessage("hello, welcome " + user.getUserName());
		} else {
			this.setMessage("sorry, no permission!");
		}
		return SUCCESS;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public void setUserService(UserService userService) {
		this.userService = userService;
	}

}
